package com.rapida.example.theme;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.rapida.theme.ThemeActivity;

public class ExampleThemeActivity extends ThemeActivity implements AdapterView.OnItemClickListener {
	private ListView mThemeList;
	private View mBgView;
	private ArrayAdapter mAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.theme);
		mThemeList = (ListView) findViewById(R.id.list);
		mBgView = findViewById(R.id.background);
		mBgView.setBackgroundColor(this.getResources().getColor(R.color.bg));
		mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getThemes());
		mThemeList.setAdapter(mAdapter);
		mThemeList.setOnItemClickListener(this);
	}

	@Override
	public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
		applyTheme(getThemes().get(i));
	}

	@Override
	public void OnThemeChanged(String newThemePackageName) {
		super.OnThemeChanged(newThemePackageName);
		mBgView.setBackgroundColor(getThemeResources().getColor(R.color.bg));
		mAdapter.notifyDataSetChanged();
	}
}